package com.lfy.aop;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
@Aspect
@Slf4j
public class TestAlifor {
    @SneakyThrows
    @Around("@annotation(com.lfy.aop.LimitingTest)")
    public Object alifor(ProceedingJoinPoint point){
        Method signature = ((MethodSignature) point.getSignature()).getMethod();

        LimitingTest annotation = AnnotationUtils.findAnnotation(signature, LimitingTest.class);
        log.info("test的值："+annotation.test());
        log.info("value的值"+annotation.value());

        return point.proceed();
    }
    @SneakyThrows
    @Around("@annotation(testTow)")
    public Object t(ProceedingJoinPoint point,LimitingTestTow testTow){
        Method signature = ((MethodSignature) point.getSignature()).getMethod();

        log.info("tow value的值"+testTow.value());

        return point.proceed();
    }
}
